Skip to content

Display proper download state in remote results view#1242

Merged
aeisenberg merged 6 commits intomainfrom
aeisenberg/analysis-results-on-restart
Mar 31, 2022
Merged

Display proper download state in remote results view#1242
aeisenberg merged 6 commits intomainfrom
aeisenberg/analysis-results-on-restart

Conversation

@aeisenberg
Copy link
Copy Markdown
Contributor

Before displaying any results for a remote query, ensure that all
downloaded results are in memory. This ensures the proper download icon
is displayed alongside each NWO.

Checklist

  • [n/a] CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@aeisenberg aeisenberg requested review from a team as code owners March 28, 2022 18:48
Before displaying any results for a remote query, ensure that all
downloaded results are in memory. This ensures the proper download icon
is displayed alongside each NWO.
@aeisenberg aeisenberg force-pushed the aeisenberg/analysis-results-on-restart branch from f40af17 to 0383a91 Compare March 28, 2022 19:38
Comment thread extensions/ql-vscode/src/remote-queries/download-link.ts Outdated
Comment thread extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts Outdated
Comment thread extensions/ql-vscode/test/pure-tests/sarif-processing.test.ts Outdated
Comment thread extensions/ql-vscode/src/vscode-tests/no-workspace/download-link.test.ts Outdated
Comment thread extensions/ql-vscode/src/remote-queries/analyses-results-manager.ts Outdated
}


public async loadDownloadedArtifacts(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really loadDownloadedAnalyses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that this is about loading the already downloaded analyses into memory.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my comment was about the use of 'artifacts' in the name. I think loadDownloadedArtifacts should be loadDownloadedAnalyses

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah...yes...Good point. :)

public async loadDownloadedArtifacts(
allAnalysesToCheck: AnalysisSummary[]
) {
const allDownloadedAnalyses = await asyncFilter(allAnalysesToCheck, x => this.isDownloadedNotInMemory(x));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadAnalysesResults checks if an analysis is already in memory and doesn't attempt to download if it is. So we can simplify this to:

const allDownloadedAnalyses = await asyncFilter(allAnalysesToCheck, x => this.isAnalysisDownloaded(x));

(Note I've appended the function name with Analysis to match the convention used in the rest of the file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a name change only that you are suggesting? If so, would it be better to have isAnalysisDownloadedNotInMemory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting removing the part that it checks if the analysis is already in memory, since that is already happening by loadAnalysesResults which is being called by this function. And once we remove that part I think the name can be simplified too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So isAnalysisDownloadedNotInMemory changes to:

private async isAnalysisDownloaded(analysis: AnalysisSummary): Promise<boolean> {
    return await fs.pathExists(createDownloadPath(this.storagePath, analysis.downloadLink));
  }

and here the code changes to

const allDownloadedAnalyses = await asyncFilter(allAnalysesToCheck, x => this.isAnalysisDownloaded(x));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah...yes. That is simpler.

@aeisenberg aeisenberg force-pushed the aeisenberg/analysis-results-on-restart branch from de06ed1 to 8daa92a Compare March 29, 2022 23:04
}


public async loadDownloadedArtifacts(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my comment was about the use of 'artifacts' in the name. I think loadDownloadedArtifacts should be loadDownloadedAnalyses

Comment thread extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts Outdated
Comment thread extensions/ql-vscode/src/vscode-tests/no-workspace/download-link.test.ts Outdated
@aeisenberg aeisenberg merged commit 0efd029 into main Mar 31, 2022
@aeisenberg aeisenberg deleted the aeisenberg/analysis-results-on-restart branch March 31, 2022 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants